﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using BigPang.Common.Service;
using BigPang.Game;
using System.Threading.Tasks;

namespace BigPang
{
    public partial class LoginForm : Form
    {
        public LoginForm()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            Program.mGameService = Net.Client<IGameService>.Connect(this.textBox1.Text, new GamePlay(), "GameService");

            string name = textBox2.Text;
            TaskEx.Run( () =>
                {
                    Program.mGameService.Join(name, out Program.mPlayerId);
                }
                );

            this.DialogResult = DialogResult.OK;
        }

        private void button2_Click(object sender, EventArgs e)
        {
            new EditorForm().ShowDialog();
        }

        private void pictureBox1_Click(object sender, EventArgs e)
        {
            if (colorDialog1.ShowDialog() == DialogResult.OK)
            {
                pictureBox1.BackColor = colorDialog1.Color;
            }
        }
    }
}
